<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>河南青少年机器人竞赛</title>
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link href="css/mui.min.css" rel="stylesheet"/>
	<link href="css/style.css" rel="stylesheet"/>
	<style>
		.mui-input-row{border-bottom: 1px solid #ccc;}
		.mui-input-row label{font-size: 16px;}
	</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
	<a id="back" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">队伍管理</h1>
	<a onclick="addTeam()" class="mui-icon-right-nav mui-pull-right"><span class="mui-icon mui-icon-plus"></span></a>
</header>
<div class="mui-content">
	<div style="padding: 10px 10px;">
		<div id="segmentedControl" class="mui-segmented-control">
			<a class="mui-control-item" data-value="1" style="touch-action: none;">
				市赛
			</a>
			<a class="mui-control-item mui-active" data-value="2" style="touch-action: none;">
				省赛
			</a>
		</div>
	</div>
	<div class="city-teamList" style="display: none;">
		<div class="btn-area mui-button-row" style="position: fixed;bottom: 0;width:100%;z-index: 10;">
			<button id="confirm-btn" type="button" class="mui-btn mui-btn-block mui-btn-success" style="margin-bottom: 0;padding: 10px 0;">去确认</button>
		</div>
	</div>
	<div class="province-teamList">
		<!--<div class="mui-card">-->
		<!--<div class="mui-input-row mui-checkbox">-->
		<!--<label>机器人挑战(A类) -初中组</label>-->
		<!--<input name="checkbox1" value="Item 1" type="checkbox">-->
		<!--</div>-->

		<!--<div class="mui-card-content">-->
		<!--<div class="mui-card-content-inner robot-team-list">-->
		<!--<h4 style="text-align: center;">郑州中学一队</h4>-->
		<!--<div class="title">-->
		<!--组员-->
		<!--</div>-->
		<!--<ul class="mui-table-view">-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>张三(男) 	<span class="mui-pull-right">衣服尺码:XLL</span>-->
		<!--<div>410321198602021234</div>-->
		<!--</li>-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>李四(男) 	<span class="mui-pull-right">衣服尺码:XLL</span>-->
		<!--<div>410321198602021234</div>-->
		<!--</li>-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>张三(男) 	<span class="mui-pull-right">衣服尺码:XLL</span>-->
		<!--<div>410321198602021234</div>-->
		<!--</li>-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>李四(男) 	<span class="mui-pull-right">衣服尺码:XLL</span>-->
		<!--<div>410321198602021234</div>-->
		<!--</li>-->
		<!--</ul>-->
		<!--<div class="title">-->
		<!--辅导老师-->
		<!--</div>-->
		<!--<ul class="mui-table-view">-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>王五 	<span class="mui-pull-right">15621344321</span>-->
		<!--</li>-->
		<!--<li class="mui-table-view-cell">-->
		<!--<span class="mui-pull-left"></span>王五 	<span class="mui-pull-right">15621344321</span>-->
		<!--</li>-->
		<!--</ul>-->
		<!--</div>-->
		<!--</div>-->
		<!--<div class="mui-card-footer">-->
		<!--<button type="button" class="mui-btn mui-btn-link">修改</button>-->
		<!--</div>-->
		<!--</div>-->
		<div class="btn-area mui-button-row" style="position: fixed;bottom: 0;width:100%;z-index: 10;">
			<button id="pay-btn" type="button" class="mui-btn mui-btn-block mui-btn-success" style="margin-bottom: 0;padding: 10px 0;">去支付</button>
		</div>
	</div>





</div>
<script src="js/mui.min.js"></script>
<script src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">

	mui.init({
		preloadPages:[{
			url:'applyTeam.html',
			id:'applyTeam.html',
			styles:{},
			extras:{
				name:'csdn'
			},//在这里添加要传递的参数
		},
		]
	});
	mui.ready(function(){
		getList()
	});
	var flag=$(".mui-active").attr("data-value");
	function getList(){
		$('.teamList').empty();
		flag=$("a.selected").attr("data-value");
		//获取当前页面是市赛还是省赛
		$.ajax({
			data:"",
			dataType:'json',//服务器返回json格式数据
			type:'get',//HTTP请求类型
			url:'../team/front/',
			//timeout:10000,//超时时间设置为10秒；
			headers:{'Content-Type':'application/json'},
			success:function(data){
				console.log(data)
				var result = data.data;
				var htmlCity="";
				var htmlProvince="";
				if(result!=null){
					mui.each(result,function(i,e){
						var rel="";
						//过滤是否为省赛
							rel+='<div class="mui-card">' +
									'<div class="mui-input-row mui-checkbox">' +
									'<label>'+e.project.name+' -初中组</label>' ;
									if(e.jiaoFei==null){
										rel+='<input name="checkbox1" value="'+e.id+'" type="checkbox">';
									}
						rel+='</div>';
							rel+='<div class="mui-card-content">' +
									'<div class="mui-card-content-inner robot-team-list">' +
									'<h4 style="text-align: center;">'+e.teamName+'</h4>' ;

							if(e.teamMembers.length>0){
								rel+='<div class="title">组员</div><ul class="mui-table-view">' ;
								mui.each(e.teamMembers,function(index,item){
									rel+=' <li class="mui-table-view-cell team-mem-item">' +
											' <span class="mui-pull-left"></span>'+item.name+'('+(item.sex==0?"男":"女")+') <span class="mui-pull-right">衣服尺码:'+item.size+'</span>' +
											' <div>'+item.idCard+'</div>' +
											' </li>' ;
								});
								rel+='</ul>';
							}
							if(e.teamLeaders.length>0){
								rel+='<div class="title">辅导老师</div><ul class="mui-table-view">' ;
								mui.each(e.teamLeaders,function(index,item){
									rel+=' <li class="mui-table-view-cell">' +
											' <span class="mui-pull-left"></span>'+item.name+' <span class="mui-pull-right">'+item.phone+'</span>' +
											' </li>' ;
								});
								rel+='</ul>';
							}
							rel+='</div></div></div>';

						if(e.templateId!=null){
							htmlProvince+=rel;
						}else{
							htmlCity+=rel;
						}
					});
					$('.city-teamList').append(htmlCity);
					$('.province-teamList').append(htmlProvince);
				}else{
					mui.toast("暂无数据",{ duration:'2000', type:'div' });
				}

			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				console.log(xhr);
				console.log(type);
				console.log(errorThrown);
			}
		});
	}
	mui("#segmentedControl").on('tap','a',function(){
		var match = $(this).attr("data-value");
		$(this).addClass("selected");
		$(this).siblings().removeClass("selected");
		if(match==1){
			$(".city-teamList").show();
			$(".province-teamList").hide();
			if($(".city-teamList .mui-card").length==0){
				mui.toast("暂无数据",{ duration:'2000', type:'div' });
			}
		}else{
			$(".city-teamList").hide();
			$(".province-teamList").show();
			if($(".province-teamList .mui-card").length==0){
				mui.toast("暂无数据",{ duration:'2000', type:'div' });
			}
		}
	});
	function addTeam(){
		//window.location.href='applyTeam.html';
		mui.openWindow({
			url:'applyTeam.html'
		});
	}
	//省赛缴费
	mui(".btn-area").on('tap','#pay-btn',function(){
		mui(this).button('loading');
		var that=this;
		var ids = "";
		var num=0;
		var order={};
		var arg=[];
		mui(".mui-checkbox input").each(function(index,item){
			if(this.checked){
				//list.push(this.value);
				ids+=this.value+",";
				num+=$(item).parent().parent().find(".team-mem-item").length;
				arg.push($(item).parent().parent().find("h4").text());
			}
			order["teamName"]=arg;
		});
		ids=ids.substring(0,ids.length-1);
		order["number"]=num;
		order["ids"]=ids;
		localStorage.setItem("order",JSON.stringify(order));
		if(ids!=""){
			//做跳转处理
			mui.openWindow({
				url:'payConfirm.html'
			});
			// $.ajax({
			// 	type: "get",
			// 	url: "../jiaofei/pay",
			// 	data: {"ids":ids},
			// 	dataType: "json",
			// 	success: function(data){
			// 		if(data.success){
			// 			mui(that).button('reset');
			// 		}else{
			// 			mui.toast(data.message,{ duration:'2000', type:'div' });
			// 		}
			// 	},
			// 	error:function(){
			// 		mui.toast('缴费出现异常，请联系管理员',{ duration:'2000', type:'div' });
			// 	}
			// });
		}else{
			mui.toast("请先勾选队伍",{ duration:'2000', type:'div' });
		}
	});
	//市赛确认
	mui(".btn-area").on('tap','#confirm-btn',function(){
		var list = new Array();
		mui(".mui-checkbox input").each(function(index,item){
			if(this.checked){
				list.push(this.value);
			}
		});
		console.log(list);
		if(list.length>0){
			//做跳转处理
		}else{
			mui.toast("请先勾选队伍",{ duration:'2000', type:'div' });
		}
	});


	mui(".mui-card-footer").on('tap','button',function(){


	});
	$("#back").click(function(){
		mui.openWindow({
			url:'index.html'
		});
	})


	// var list = new Array();
	// mui('.mui-checkbox').on('change', 'input', function() {
	// 	var value = this.checked?"true":"false";
	// 	if(value){
	// 		list.push(this.value)
	// 	}
	// 	console.log(list)
	// 	this.previousElementSibling.innerText = "checked："+value;
	// });
</script>
</body>
</html>
